import config from '@/config';
import RequestBase from '@/utils/request.js';

const baseRequest = new RequestBase(config.dutyUrl);

/** 获取班次 */
export function getShiftRule(deptId) {
  return baseRequest.get(`/dtr/shift/getShiftRuleDetailByParentDept/${deptId}`);
}

/** 获取班次 */
export function getShiftRuleDetailByDept(deptId) {
  return baseRequest.get(`/dtr/shift/getShiftRuleDetailByDept/${deptId}`);
}

/**
 * @description: 新增班前会
 * @param {*} data
 * @return {*}
 */
export function addMeeting(data) {
  return baseRequest.post('/dtr/mobile/meeting/addForPreClass', data);
}

/**
 * @description: 进行中的班前会列表
 * @param {*} pageSize
 * @param {*} pageNum
 * @param {*} isMyBacklog  Y 待办
 * @return {*}
 */
export function getList({ pageSize, pageNum, isMyBacklog } = {}) {
  return baseRequest.get('/dtr/mobile/meeting/getListForNotFinishPreClass', {
    pageSize,
    pageNum,
    isMyBacklog,
  });
}

/**
 * @description: 已完成的班前会列表
 * @param {*} data
 * @return {*}
 */
export function getListForFinish({
  classTypeName,
  keyWord,
  meetingDate,
  parentDeptId,
  pageSize,
  pageNum,
} = {}) {
  return baseRequest.get('/dtr/mobile/meeting/getListForFinishPreClass', {
    classTypeName,
    keyWord,
    meetingDate,
    parentDeptId,
    pageSize,
    pageNum,
  });
}

/**
 * @description: 获取会议所有信息
 * @param {*} meetingId
 * @return {*}
 */
export function detail(meetingId) {
  return baseRequest.get(`/dtr/team-meeting/view/${meetingId}`);
}

/**
 * @description: 签到
 * @param {*} meetingId
 * @param {*} procTaskId
 * @return {*}
 */
export function signIn({ meetingId, procTaskId } = {}) {
  return baseRequest.put('/dtr/mobile/meeting/signIn', {
    meetingId,
    procTaskId,
  });
}

/**
 * @description: 生产处理
 * @param {*} procTaskId
 * @param {*} meetingId
 * @param {*} handleContent
 * @return {*}
 */
export function scHandle({ procTaskId, meetingId, handleContent, files } = {}) {
  return baseRequest.put('/dtr/mobile/meeting/scHandle', {
    procTaskId,
    meetingId,
    handleContent,
    files,
  });
}

/**
 * @description: 设备
 * @param {*} procTaskId
 * @param {*} meetingId
 * @param {*} handleContent
 * @return {*}
 */
export function sbHandle({ procTaskId, meetingId, handleContent, files } = {}) {
  return baseRequest.put('/dtr/mobile/meeting/sbHandle', {
    procTaskId,
    meetingId,
    handleContent,
    files,
  });
}

/**
 * @description: 安全处理
 * @return {*}
 */
export function ahHandle({ meetingId, procTaskId, handleContent, files } = {}) {
  return baseRequest.put('/dtr/mobile/meeting/ahHandle', {
    meetingId,
    procTaskId,
    handleContent,
    files,
  });
}

/**
 * @description: 综合处理
 * @return {*}
 */
export function zhHandle({
  meetingId,
  procTaskId,
  handleContent,
  files,
  fileContent,
  award,
  punishment,
  notice,
} = {}) {
  return baseRequest.put('/dtr/mobile/meeting/zhHandle', {
    meetingId,
    procTaskId,
    handleContent,
    files,
    fileContent,
    award,
    punishment,
    notice,
  });
}

/**
 * @description: 总结
 * @return {*}
 */
export function summaryHandle({
  meetingId,
  procTaskId,
  actualLeaders,
  handleContent,
} = {}) {
  return baseRequest.put('/dtr/mobile/meeting/summaryHandle', {
    meetingId,
    procTaskId,
    actualLeaders,
    handleContent,
  });
}

/**
 * @description: 获取班前会评分配置
 * @return {*}
 */
export function getPreClassMeetingScoreConfigList() {
  return baseRequest.get(
    '/dtr/mobile/meeting/getPreClassMeetingScoreConfigList'
  );
}

/**
 * @description: 评分
 * @param {*} itemList
 * @param {*} meetingId
 * @param {*} procTaskId
 * @return {*}
 */
export function doScore({
  itemList,
  meetingId,
  procTaskId,
  summaryHandleContent,
} = {}) {
  return baseRequest.put('/dtr/mobile/meeting/doScore', {
    itemList,
    meetingId,
    procTaskId,
    summaryHandleContent,
  });
}

// 领导讲话
export function doSpeak(data) {
  return baseRequest.put('/dtr/mobile/meeting/leaderTalk', data);
}

/**
 * @description: 确认通过
 * @param {*} advice
 * @param {*} meetingId
 * @param {*} procTaskId
 * @return {*}
 */
export function confirmPass({ meetingId, procTaskId, advice } = {}) {
  return baseRequest.put('/dtr/mobile/meeting/confirmPass', {
    advice,
    meetingId,
    procTaskId,
  });
}

/**
 * @description: 指定回退
 * @param {*} advice
 * @param {*} meetingId
 * @param {*} procTaskId
 * @return {*}
 */
export function callBack({ meetingId, procTaskId, advice, targetNodeId } = {}) {
  return baseRequest.put('/dtr/mobile/meeting/callBack', {
    advice,
    meetingId,
    procTaskId,
    targetNodeId,
  });
}

/**
 * @description: 获取可回退节点列表
 * @param {*} taskId
 * @return {*}
 */
export function getRollbackNodes(taskId) {
  return baseRequest.get(`/dtr/common/getRollbackNodes/${taskId}`);
}

/**
 * @description: 获取上一个班组的交班情况
 * @return {*}
 */
export function getLastAdvice(data) {
  return baseRequest.get('/dtr/team-meeting/last-advice', data);
}

/**
 * @description: 获取参会人员数量
 * @return {*}
 */
export function getUserCount(meetingId) {
  return baseRequest.get(`/dtr/team-meeting/user-count?meetingId=${meetingId}`);
}

/**
 * @description:获取参会的所有人员
 * @param {*} meetingId
 * @param {*} userName
 * @return {*}
 */
export function getAllUser(meetingId, userName) {
  return baseRequest.get(
    `/dtr/team-meeting/all-user?meetingId=${meetingId}&userName=${userName}`
  );
}

/**
 * @description: 综合记录
 * @return {*}
 */
export function recordHandle(data) {
  return baseRequest.put('/dtr/team-meeting/record-Handle', data);
}

/** 获取排班事项 */
export function getShiftItem(data) {
  return baseRequest.get(`/dtr/mobile/Shifting/getItemList`, data);
}

/** 获取全部排班事项 */
export function getShiftAllItem() {
  return baseRequest.get(`/dtr/range-class/schedule/item/box/list`);
}

// 根据时间和账号获取排班事项
export function getShiftItemList(data) {
  // return baseRequest.get(`/dtr/team-meeting/item/box/list`, data);
  // 新增班前会-排班事项，与web端接口保持统一
  return baseRequest.get(`/dtr/range-class/schedule/item/box/list`, data);
}

// 根据账号、时间、排班事项获取班次
export function getShiftClassList(data) {
  return baseRequest.get('/dtr/range-class/schedule/getClassList', data);
}

// 根据账号、排班事项、班次获取职能
export function getDutyUser(data) {
  return baseRequest.get('/dtr/range-class/schedule/getDutyUserList', data);
}

// 班前会获取班次
export function getRecentClass(data) {
  return baseRequest.get('/dtr/range-class/schedule/recentClassList', data);
}
